/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.metashare.grah.test

import net.metashare.grah.logic.Equals

import net.metashare.grah.logic.Not
import net.metashare.grah.pogo.SimplePogoGraph
import net.metashare.grah.Graph

import net.metashare.grah.Node

/**
 *
 * @author dsherema
 */

// test node



ExpandoMetaClass.enableGlobally()

def Graph g = new SimplePogoGraph()

def TextObject a = new TextObject("foo-a")
def TextObject b = new TextObject("foo-b")
def TextObject c = new TextObject("foo-c")
//println "calling wrapped method on node: " + n.wrappableTextMethod()


g.add(a)
g.add(b)
def List nodes = g.nodes(new Equals(a))
println "nodes that equal to $a.text"
nodes.each() { node ->
  println "not  A: " + node.text
  println "wrapped object: " + node.object
  println "instance of node: " + node instanceof Node
}


nodes = g.nodes(new Not( new Equals(b)))
println "nodes that are NOT equal to $b.text"
nodes.each() { Node node ->
  println "not  B: " + node.text

  println "wrapped object: " + node.object
  println "instance of node: " + node instanceof Node
  
}
g.connect(a, b)
g.direct(b, c)

g.dump()
nodes = g.nodes()
println "All nodes: $nodes.each(){it.text}" 

    

